<?php

use Illuminate\Http\Request;
use App\Model\Product;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
//用户路由：注册、登陆，退出
Route::post('register','Auth\RegisterController@createUser');
Route::post('login','Auth\LoginController@login')->name('login');
Route::post('logout', 'Auth\LoginController@logout');
Route::get('wxuserinfo', 'Auth\LoginController@getWxUserInfo');

//Route::group(['middleware' => 'auth:api'],function(){
//    Route::get('products','API\ProductController@index');          //返回当前产品表中的所有的产品数据
//    Route::get('products/{id}','API\ProductController@show');       //根据指定的id获取对应的产品信息
//    Route::post('products','API\ProductController@store');          //创建一个新的产品数据
//    Route::post('products/{id}','API\ProductController@update');    //更新产品的数据
//    Route::delete('products/{id}','API\ProductController@delete');  //删除产品
//});

//产品路由
Route::get('products','API\ProductController@index');          //返回当前产品表中的所有的产品数据
Route::get('products/{id}','API\ProductController@show');       //根据指定的id获取对应的产品信息
Route::post('products','API\ProductController@store');          //创建一个新的产品数据
Route::post('products/{id}','API\ProductController@update');    //更新产品的数据
Route::delete('products/{id}','API\ProductController@delete');  //删除产品

//文件上传的路由
Route::post('upload','API\FileController@uploadFile');

//秒杀活动路由
Route::get('seckillgoods','API\SecKillGoodsController@index');          //返回当前秒杀活动表中的所有的产品数据
Route::get('seckillgoods/{id}','API\SecKillGoodsController@show');       //根据指定的id获取对应的秒杀活动信息
Route::post('seckillgoods','API\SecKillGoodsController@store');          //创建一个新的秒杀活动数据
Route::post('seckillgoods/{id}','API\SecKillGoodsController@update');    //更新秒杀活动的数据
Route::post('publishseckillgoods/{id}','API\SecKillGoodsController@publishSeckillGoods');    //发布秒杀活动
Route::delete('seckillgoods/{id}','API\SecKillGoodsController@delete');  //删除秒杀活动


//文件处理路由
Route::get('documents','API\DocumentController@index');          //查询展示文件数据
Route::get('documents/{id}','API\DocumentController@show');       //根据id获取展示文件的数据
Route::get('documentsbyshowtype/{showtype}','API\DocumentController@getDocumentByShowType');//根据展示类型获取到对应的文件数据
Route::post('documents','API\DocumentController@store');          //创建一个新的展示文件
Route::post('updatestatus/{id}','API\DocumentController@updateStatus'); //修改文件状态
Route::post('documents/{id}','API\DocumentController@update'); //修改文件状态
Route::delete('documents/{id}','API\DocumentController@delete');  //删除展示文件数据


//门店处理路由
Route::get('shops','API\ShopController@index');          //查询门店数据
Route::get('shops/{id}','API\ShopController@show');       //根据id获取门店的数据
Route::post('shops','API\ShopController@store');          //创建一个新的门店
Route::delete('shops/{id}','API\ShopController@delete');  //删除门店数据